sysroot: Port some small cleanup code to fd-relative
authorColin Walters <walters@verbum.org>
Wed, 14 Sep 2016 01:26:38 +0000 (21:26 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Wed, 14 Sep 2016 10:13:12 +0000 (10:13 +0000)
Just a quick patch since I saw this function scroll by in Emacs and it
was too ugly not to be rewritten.

Closes: #510
Approved by: giuseppe

src/libostree/ostree-sysroot-deploy.c

index a49428d28e994b3f9fa16f01c9bf695bbfd047a9..79f9c9f3b83e1dcd080b695b4d47006707b2f13b 100644 (file)
@@ -1635,25 +1635,28 @@ cleanup_legacy_current_symlinks (OstreeSysroot         *self,
                                  GCancellable          *cancellable,
                                  GError               **error)
 {
-  gboolean ret = FALSE;
   guint i;
-  g_autoptr(GHashTable) created_current_for_osname =
-    g_hash_table_new (g_str_hash, g_str_equal);
+  g_autoptr(GString) buf = g_string_new ("");
 
   for (i = 0; i < self->deployments->len; i++)
     {
       OstreeDeployment *deployment = self->deployments->pdata[i];
       const char *osname = ostree_deployment_get_osname (deployment);
-      g_autoptr(GFile) osdir = ot_gfile_resolve_path_printf (self->path, "ostree/deploy/%s", osname);
-      g_autoptr(GFile) legacy_link = g_file_get_child (osdir, "current");
 
-      if (!ot_gfile_ensure_unlinked (legacy_link, cancellable, error))
-        goto out;
+      g_string_truncate (buf, 0);
+      g_string_append_printf (buf, "ostree/deploy/%s/current", osname);
+
+      if (unlinkat (self->sysroot_fd, buf->str, 0) < 0)
+        {
+          if (errno != ENOENT)
+            {
+              glnx_set_error_from_errno (error);
+              return FALSE;
+            }
+        }
     }
 
-  ret = TRUE;
- out:
-  return ret;
+  return TRUE;
 }
 
 static gboolean